/*
 * Copyright 2016-present the IoT DC3 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.github.pnoker.center.data.mqtt.service.impl;

import io.github.pnoker.common.mqtt.entity.MqttMessage;
import io.github.pnoker.common.mqtt.service.MqttReceiveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author pnoker
 * @since 2022.1.0
 * @desc 正常情况所有设备从对应驱动模块来处理，例如 ： 设备 ---(MQTT)---> MQTT驱动 ---(RabbitMQ)---> DC3-Center-Data
 * 这个类是直接处理 设备的MQTT消息的, 一般情况下是不使用的
 */
@Slf4j
@Service
public class MqttReceiveServiceImpl implements MqttReceiveService {
    @Override
    public void receiveValue(MqttMessage mqttMessage) {
        // 处理单条MQTT消息
        log.info("收到单条MQTT消息: {}", mqttMessage);
        // TODO: 在此处添加具体的消息处理逻辑
    }

    @Override
    public void receiveValues(List<MqttMessage> mqttMessageList) {
        // 批量处理多条MQTT消息
        log.info("收到批量MQTT消息, 消息数量: {}", mqttMessageList.size());
        mqttMessageList.forEach(message -> log.debug("消息内容: {}", message));
        // TODO: 在此处添加具体的批量消息处理逻辑
    }
}
